﻿#include <iostream>
#include <cstring>
#include <windows.h> // 包含 Windows API 的头文件

int main() {
    const size_t bufferSize = 10;
    char source[bufferSize] = "123456789";
    char destination[bufferSize] = { 0 };
    errno_t err;

    std::cout << "Before memcpy: " << destination << std::endl;

    printf("s = %p t = %p\n",source, destination);

    // 使用 memcpy
    memcpy(destination, source, bufferSize - 1);
    std::cout << "After memcpy: " << destination << std::endl;

    // 显示 MessageBox
    MessageBox(NULL, L"memcpy completed!", L"Notification", MB_OK);

    // 修改源数据
    //source[0] = 'B';
    //memset(destination, 0, bufferSize); // 清空 destination 以便重新使用

    //std::cout << "Before memcpy_s: " << destination << std::endl;

    //// 使用 memcpy_s
    err = memcpy_s(destination, bufferSize, source, bufferSize - 1);
    //if (err != 0) {
    //    std::cerr << "memcpy_s failed: " << err << std::endl;
    //    return 1; // 或处理错误
    //}
    std::cout << "After memcpy_s: " << destination << std::endl;

    //// 显示另一个 MessageBox
    //MessageBox(NULL, L"memcpy_s completed!", L"Notification", MB_OK);

    return 0;
}














